package me.acomma.groot.application.role;

import me.acomma.groot.domain.role.Role;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.List;

@Mapper(componentModel = "spring")
public interface RoleAssembler {
    @Mappings({
            @Mapping(target = "roleId", source = "roleId.id"),
    })
    RoleData toRoleData(Role role);

    @Mappings({
            @Mapping(target = "roleId", source = "roleId.id"),
    })
    List<RoleData> toRoleDataList(List<Role> roles);

    @Mappings({
            @Mapping(target = "roleId", ignore = true),
            @Mapping(target = "createTime", ignore = true),
            @Mapping(target = "id", ignore = true),
            @Mapping(target = "updateTime", ignore = true)
    })
    Role toRole(PageQueryRoleCommand command);
}
